#include "DAMIAO/damiao.h"
#include "DJI/dji.h"
#include "rtdef.h"
#include "rtthread.h"

#define LOG_TAG              "motor_task"
#define LOG_LVL              LOG_LVL_DBG
#include <ulog.h>


static void motor_control_thread_entry(void *parameter)
{
    while (1) 
    {    
        DJIMotorControl();    
        DMMotorcontrol();
        rt_thread_mdelay(2);
    }
}

int motor_thread_entry_init(void)
{
    rt_err_t ret = RT_EOK;

    rt_thread_t thread = rt_thread_create("motor_control", motor_control_thread_entry, RT_NULL, 2048, 15, 10);
    /* 创建成功则启动线程 */
    if (thread != RT_NULL)
    {
        rt_thread_startup(thread);
    }
    else
    {
        ret = RT_ERROR;
    }

    LOG_D("motor thread start success!\n");

    return ret;
}

INIT_APP_EXPORT(motor_thread_entry_init);
